import QtQuick 2.6
import QtQuick.Layouts 1.1

import "../Base/UiBase"
import "../Base/Config"
import Code 1.0

Rectangle {
    width: parent.width
    height: col.height
    color: index % 2 ? Color.foreground : Color.foregroundDarker

    Column {
        id: col
        width: parent.width
        spacing: 0

        RowLayout {
            width: parent.width
            height: 100 * Size.ratio
            spacing: 0
            Item {
                Layout.preferredWidth: 100 * Size.ratio
                Layout.preferredHeight: 100 * Size.ratio
                HeadHolder {
                    anchors.centerIn: parent
                    SvgzImage {
                        width: 80 * Size.ratio
                        height: 80 * Size.ratio
                        source: user.head
                    }
                }
            }
            ColumnLayout {
                Layout.fillWidth: true
                Layout.fillHeight: true
                spacing: 0
                Text {
                    Layout.fillWidth: true
                    Layout.topMargin: 20 * Size.ratio
                    text: user.name
                    font.pixelSize: Size.normalFont
                }
                Text {
                    Layout.fillWidth: true
                    Layout.rightMargin: 80 * Size.ratio
                    Layout.topMargin: 10 * Size.ratio
                    clip: true
                    text: messageText
                    color: Color.virtualInput
                    font.pixelSize: Size.normalFont
                    elide: Text.ElideRight
                }
            }
        }

        // image row
        Rectangle {
            width: parent.width
            height: 120 * Size.ratio
            color: Color.background
            anchors {
                left: parent.left
                leftMargin: 85 * Size.ratio
                right: parent.right
                rightMargin: 25 * Size.ratio
            }
            RowLayout {
                id: imageRow
                width: parent.width
                height: parent.height
                visible: ref.image !== undefined ? true : false
                spacing: 0
                SvgzImage {
                    Layout.preferredWidth: parent.height
                    Layout.preferredHeight: parent.height
                    width: parent.height
                    height: parent.height
                    source: ref.image ? ref.image : ""
                }
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text: ref.user.name
                    font.pixelSize: Size.normalFont
                    color: Color.main
                }
                Text {
                    Layout.fillWidth: true
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("的图片  ", "评论-XXX的图片  ")
                    font.pixelSize: Size.normalFont
                }
            } // end image row

            // text row
            RowLayout {
                id: textRow
                width: parent.width
                height: parent.height
                visible: ref.image !== undefined ? false : true
                spacing: 0
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text: ref.user.name
                    font.pixelSize: Size.normalFont
                    color: Color.main
                }
                Text {
                    Layout.fillWidth: true
                    anchors.verticalCenter: parent.verticalCenter
                    text: ":" + ref.text
                    font.pixelSize: Size.normalFont
                    elide: Text.ElideRight
                }
            } // end text row
        }
    }
    BottomDivider {
    }
}
